package com.zhiyou.app.pojo.enums;


import lombok.Getter;

import java.util.Arrays;

/**
 * @Description 设备类型枚举
 * @Author : bind
 * @Date : 2022-06-14 14:41
 */
@Getter
public enum UserStatusEnum {

    /**
     *
     */
    NORMAL("1", "正常"),
    DISABLED("0", "禁用"),
    CLOCKED("-1", "锁定");

    public String code;
    public String name;

    UserStatusEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public static boolean contains(String s) {
        return Arrays.stream(UserStatusEnum.values()).map(UserStatusEnum::toString).anyMatch(s::equals);
    }

    @Override
    public String toString() {
        return String.valueOf(this.code);
    }

    public static UserStatusEnum parse(String code) {
        return Arrays.stream(UserStatusEnum.values()).filter(s -> s.code.equals(code)).findFirst().orElse(null);
    }
}
